﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace diploma.core.data.objects
{
    public class Statement : DataObject
    {
        private string content;
        private long id_type;
        private long themeId;
        public Statement(long _id, string _title, string _content, long _id_type, long _themeId)
            : base(_id, _title)
        {
            content = _content;
            id_type = _id_type;
            themeId = _themeId;
        }

        public long ThemeId
        {
            get
            {
                return themeId;
            }
        }

        public void SetTheme (long _value)
        {
            themeId = _value;
            DataRouter.Instance.Act(DataActions.update, this.Type, this);
        }

        public string Title
        {
            get
            {
                return textField;
            }
        }

        public long IdType
        {
            get
            {
                return id_type;
            }
        }

        public string Content
        {
            get
            {
                return content;
            }
        }

        public void SetTitle(string _value, bool _innerDataSourceChanges)
        {
            SetTextField(_value, _innerDataSourceChanges);
        }

        public void SetTitle(string _value)
        {
            SetTextField(_value);
        }

        public void SetContent(string _value, bool _innerDataSourceChanges)
        {
            content = _value;
            if (!_innerDataSourceChanges)
            {
                DataRouter.Instance.Act(DataActions.update, this.Type, this);
            }
        }
        public void SetIdType(long _value)
        {
            SetIdType(_value, false);
        }

        public void SetIdType(long _value, bool _innerDataSourceChanges)
        {
            id_type = _value;
            if (!_innerDataSourceChanges)
            {
                DataRouter.Instance.Act(DataActions.update, this.Type, this);
            }
        }

        public override DataObjectTypes Type
        {
            get
            {
                return DataObjectTypes.Statement;
            }
        }

        #region ISerializable Members

        public override void FromStream(System.IO.Stream _stream)
        {
            base.FromStream(_stream);
            content = ByteSerialization.StringFromBytes(_stream);
        }

        public override void ToStream(System.IO.Stream _stream)
        {
            base.ToStream(_stream);
            ByteSerialization.StringToBytes(_stream, content);
        }

        #endregion
    }
}
